/**  
* Copyright (c) 2008, Noel Lynch All rights reserved. Redistribution and use  
* in source and binary forms, with or without modification, are permitted  
* provided that the following conditions are met: Redistributions of source  
* code must retain the above copyright notice, this list of conditions and the  
* following disclaimer. Redistributions in binary form must reproduce the above  
* copyright notice, this list of conditions and the following disclaimer in the  
* documentation and/or other materials provided with the distribution. Neither  
* the name of Noel Lynch nor the names of contributors may be used to  
* endorse or promote products derived from this software without specific prior  
* written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT  
* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A  
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR  
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,  
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,  
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;  
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,  
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR  
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF  
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
*/
// Aug 5, 2008

package com.sceneworker.editors.spatialtransformereditor;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;

import net.miginfocom.swing.MigLayout;

import com.jme.animation.SpatialTransformer;
import com.myjavautils.swing.MigLayoutUtils;
import com.myjavautils.swing.SwingComponentFactory;

public class SpatialTransformerPanel extends JPanel {

	private		JDialog		mcl_owner;
	
	public SpatialTransformerPanel(JDialog cl_dlg, SpatialTransformer cl_tx) {
		super();
		
		mcl_owner = cl_dlg;
		build(cl_tx);
	}
	
	private	void
	build(SpatialTransformer cl_tx) {
		setLayout(new MigLayout("inset 5"));
		SpatialTransformerTimeLinePanel		lcl_panel = new SpatialTransformerTimeLinePanel(cl_tx);
		
		final	SpatialTransformer		lcl_tx = cl_tx;
		
		JButton		lcl_done = SwingComponentFactory.makeAButton("Done");
		lcl_done.addActionListener(new ActionListener() {

			public void actionPerformed(ActionEvent cl_e) {
				mcl_owner.setVisible(false);
				try {
					lcl_tx.setMinTime(lcl_tx.keyframes.get(0).time);
					lcl_tx.setMaxTime(lcl_tx.keyframes.get(lcl_tx.keyframes.size() - 1).time);
					lcl_tx.setActive(true);
				} catch (RuntimeException e) {
					// TODO Auto-generated catch block
					return;
				}
			}
			
		});
		
		add(lcl_panel, "width 100%, wrap");
		MigLayoutUtils.makeRightAlignedButtonBar(this, lcl_done);
	}

	
}
